<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0"?>
<?php
error_reporting(0);
ini_set('display_errors', FALSE);
require_once './config/config.php';
require_once './model/products.php';
require_once './model/blog.php';
require_once './Pagination.php';
require_once './model/myfunctions.php';
$fc= new MyFunctions();
$link=  isset($_GET['id_cat'])?('&id_cat='.$_GET['id_cat'].'&'):'&';
$params = array(
    'offset' => isset($_GET['page']) ? $_GET['page'] : 1,
    'id_cat' => isset($_GET['id_cat']) ? $_GET['id_cat'] : NULL,
    'param'=>  isset($_GET['type'])?('?type='.$_GET['type'].$link):('?q='.$_GET['q'].'&'),
    'q'=>  isset($_GET['q'])?$_GET['q']:NULL,
);
if($_GET['type']=="p"||isset($_GET['q']))
{
    $obj_products= new Products();
    $total=$obj_products->count($params);
    $list=$obj_products->select($params);
}
else if($_GET['type']=="b")
{
    $obj_blogs= new Blog();
    $total=$obj_blogs->count();
    $list=$obj_blogs->select($params);
}
$list?'':$fc->redirectTo404();
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-language" content="en"><meta name="robots" content="all,follow"><meta name="author" lang="en" content="All: Your name [www.url.com]; e-mail: info@url.com"><meta name="copyright" lang="en" content="Webdesign: Nuvio [www.nuvio.cz]; e-mail: ahoj@nuvio.cz"><meta name="description" content="..."><meta name="keywords" content="..."><link rel="stylesheet" media="screen,projection" type="text/css" href="<?php echo PATH_CSS;?>reset.css"><link rel="stylesheet" media="screen,projection" type="text/css" href="<?php echo PATH_CSS;?>main.css"><!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="<?php echo PATH_CSS;?>main-msie.css" /><![endif]--><link rel="stylesheet" media="screen,projection" type="text/css" href="<?php echo PATH_CSS;?>style.css"><link rel="stylesheet" media="screen,projection" type="text/css" href="<?php echo PATH_CSS;?>tsc_pagination.css"><link rel="stylesheet" media="print" type="text/css" href="<?php echo PATH_CSS;?>print.css"><title>Impress</title></head><body>

<div id="main">

    <!-- Header -->
    <?php require_once'./header.php'; ?><!-- /header -->
    
    <!-- Tray -->
    <?php require_once'./tray.php'; ?> <!-- /tray -->

    <!-- Promo -->
    
<div id="col-top"></div>
    
<?php foreach ($list as $item):?>
<div id="col" class="box">   
    <div id="col-browser"><a href="detail.php?type=<?php if(empty($_GET['type'])){echo "p";} echo $_GET['type'];?>&id=<?php echo $item['id'];?>"><img src="<?php echo PATH_PRODUCTS_IMAGE.$item['thumb'];?>" width="255" height="177" alt=""></a></div> 
        
        <div id="col-text">

            <h2 id="slogan"><a href="detail.php?type=<?php if(empty($_GET['type'])){echo "p";} echo $_GET['type'];?>&id=<?php echo $item['id'];?>" style="text-decoration: none;"><?php echo $item['name'];?></a></h2>
            
            <p><?php echo $item['overview'];?></p>
            
            

        </div> <!-- /col-text -->
    
</div>
<?php endforeach;?>
 <!-- /col -->
    <div id="col-bottom"></div>
    <ul class="tsc_pagination tsc_paginationA tsc_paginationA01">
         <?php
    $pagination = new Pagination();
    $params = array_merge($params, array(
        'current_page' => isset($_GET['page']) ? $_GET['page'] : 1,
        'total_page' => (ceil($total / PER_PAGE)),
        'file' => 'list.php'
    ));
    if($total>PER_PAGE)
    {
         echo $pagination->display($params);
    }
    ?>
    </ul>
     <!-- /cols2 -->
    

    <hr class="noscreen"><!-- Footer --><div id="footer">

        <!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->
        <p class="f-right"><a href="http://www.nuviotemplates.com/">Free web templates</a> presented by <a href="http://www.qartin.cz/">QARTIN</a> – Our tip: <a href="http://last-minute.invia.pl">Wakacje</a> <a href="http://dovolenka.invia.sk">Dovolenka</a></p>
        <!-- Do you want remove this backlinks? Look at www.nuviotemplates.com/payment.php -->

        <p>Copyright ©&nbsp;2014 <strong><a href="#">Họ và tên - MSSV - Số Máy - Số Đề</a></strong>, All Rights Reserved ®
</p>

    </div> <!-- /footer -->

</div> <!-- /main -->


<style>.tb_button {padding:1px;cursor:pointer;border-right: 1px solid #8b8b8b;border-left: 1px solid #FFF;border-bottom: 1px solid #fff;}.tb_button.hover {borer:2px outset #def; background-color: #f8f8f8 !important;}.ws_toolbar {z-index:100000} .ws_toolbar .ws_tb_btn {cursor:pointer;border:1px solid #555;padding:3px}   .tb_highlight{background-color:yellow} .tb_hide {visibility:hidden} .ws_toolbar img {padding:2px;margin:0px}</style></body></html>